package com.trover.myapplication.ui.login

import com.trover.myapplication.core.http.BaseRepository
import com.trover.myapplication.core.http.RetrofitClientFactory
import com.trover.myapplication.entity.LoginEntity
import com.trover.myapplication.core.http.apimodel.Result

class LoginRepository : BaseRepository() {

    suspend fun login(userName: String, password: String): Result<LoginEntity> {
        return safeApiCall(call = { requestLogin(userName, password) }, errorMsg = "")
    }

    private suspend fun requestLogin(userName: String, password: String): Result<LoginEntity> {
        val response = RetrofitClientFactory.service.login(userName, password)
        return Result.Success(response)
    }
}